<?php 
header('Content-Length: '.strlen($data).'');
header("Content-type: image/jpg");
echo $data;